# io

# StringIO
from io import StringIO

cache_file = StringIO()

print(cache_file.write('Hello World'))  # 11
print(cache_file.seek(0))  # 0
print(cache_file.read())  # Hello World
print(cache_file.getvalue())  # Hello World
print(cache_file.close())  # None

# BytesIO
from io import BytesIO

byte_file = BytesIO()
print(byte_file.write(b'I love you'))  # 10
print(byte_file.getbuffer())  # <memory at 0x000001F169B2D4C8>
print(byte_file.getvalue())  # b'I love you'
print(byte_file.seek(0))  # 0
print(byte_file.read())  # b'I love you'
print(byte_file.close())  # None
